package com.x.erp.manage;

import java.util.List;

import com.x.erp.dao.CityDao;
import com.x.erp.dao.ProvinceDao;
import com.x.erp.model.City;
import com.x.erp.model.Province;
import com.x.framework.exception.BusinessException;
import com.x.framework.exception.ExceptionCode;
import com.x.framework.manage.BaseManage;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class ProvinceManage extends BaseManage {

    @Autowired
    private ProvinceDao provinceDao;

	@Autowired
	private CityDao cityDao;
    
    public ProvinceManage() {
    }

	public List<Province> selectProvinceList(Province province) throws Exception {
		return provinceDao.selectProvinceList(province);
	}

	/**
	 * 获取启辕合作市场的省份列表(带城市)
	 * @param province
	 * @return
	 * @throws Exception
	 */
	public List<Province> selectCooperationProvinceList(Province province) throws Exception {
		List<Province> provinces = provinceDao.selectCooperationProvinceList(province);
		City cityTemp = null;
		for (Province provinceTemp : provinces) {
			cityTemp = new City ();
			cityTemp.setProvinceId (provinceTemp.getProvinceId ());
			List<City> citys = cityDao.selectCooperationCityList (cityTemp);
			provinceTemp.setCitys (citys);
		}
		return provinces;
	}
}
